/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-java-base
 * @Title 模拟教师
 * @Description *
 * @Package designmodel.observe2
 * @date 2021/3/4 11:43 上午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package designmodel.observe2;

import designmodel.observe2.delegate.Event;
import designmodel.observe2.delegate.EventHandler;
import designmodel.observe2.delegate.IEvent;
import designmodel.observe2.delegate.IEventHandler;
import designmodel.observe2.observer.ChenDaLei;
import designmodel.observe2.observer.LiuYiBan;
import designmodel.observe2.observer.WangErLang;

import java.util.ArrayList;

public class ClassRoom2 {

    public static void main(String[] args) {

        try {
            IEventHandler eventHandler = new EventHandler(new ArrayList<>());

            ChenDaLei chenDaLei = new ChenDaLei();
            WangErLang wangErLang = new WangErLang();
            LiuYiBan liuYiBan = new LiuYiBan();

            String action = "老师来啦!";
            String smt = "家庭作业";

            //添加事件委托
            eventHandler.addEvent(chenDaLei, "closeDYTV", action)
                    .addEvent(wangErLang, "hideMiniBook", action)
                    .addEvent(liuYiBan, "shutDownEarPhone", action, smt);

            //通知
            eventHandler.notifyX();

        } catch (Exception e) {
            System.err.println("出现异常啦!" + e.getMessage());
        }


    }
}
